<template><div><h2 id="组件" tabindex="-1"><a class="header-anchor" href="#组件"><span>组件</span></a></h2>
<p>组件是 Yii 应用程序的主要基石。一个组件通常是 <code v-pre>yii\base\Component</code> 类或其子类的实例，与其他类相比，它有以下几个特色功能：</p>
<ul>
<li><a href="https://learnku.com/docs/yii-framework/2.0.x/attribute/12069" target="_blank" rel="noopener noreferrer">属性（Property）</a></li>
<li><a href="https://learnku.com/docs/yii-framework/2.0.x/event/12070" target="_blank" rel="noopener noreferrer">事件（Event）</a></li>
<li><a href="https://learnku.com/docs/yii-framework/2.0.x/behavior/12071" target="_blank" rel="noopener noreferrer">行为（Behavior）</a></li>
</ul>
<p>这些功能，或单独使用，或彼此配合，它们的应用让 Yii 的类变得更加灵活和易用。</p>
<p>组件功能的强大，也使得它们比常规的对象稍重一些，因为它们需要使用额外的内存和 CPU 开销来处理事件和行为。如果你不需要这两项功能，可以继承它的的父类 <code v-pre>yii\base\Object</code>。这样，组件可以像普通 PHP 对象一样高效，同时还支持属性功能。</p>
<h2 id="自定义组件" tabindex="-1"><a class="header-anchor" href="#自定义组件"><span>自定义组件</span></a></h2>
<p>当继承 <code v-pre>yii\base\Component</code> 或 <code v-pre>yii\base\Object</code> 时，推荐你使用如下的编码风格：</p>
<ul>
<li>若你需要重写构造方法（Constructor），传入 <code v-pre>$config</code> 作为构造器方法<em>最后一个</em>参数，然后把它传递给父类的构造方法。</li>
<li>永远在你重写的构造方法<em>结尾处</em>调用一下父类的构造方法。</li>
<li>如果你重写了 [[yii\base\BaseObject::init()]] 方法，请确保你在 <code v-pre>init</code> 方法的<em>开头处</em>调用了父类的 <code v-pre>init</code> 方法。</li>
</ul>
<p>例子如下：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token php language-php"><span class="token delimiter important">&lt;?php</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">namespace</span> <span class="token package">yii<span class="token punctuation">\</span>components<span class="token punctuation">\</span>MyClass</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">yii<span class="token punctuation">\</span>base<span class="token punctuation">\</span>BaseObject</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">MyClass</span> <span class="token keyword">extends</span> <span class="token class-name">BaseObject</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token variable">$prop1</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token variable">$prop2</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">__construct</span><span class="token punctuation">(</span><span class="token variable">$param1</span><span class="token punctuation">,</span> <span class="token variable">$param2</span><span class="token punctuation">,</span> <span class="token variable">$config</span> <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token comment">// ... 在应用配置之前初始化</span></span>
<span class="line"></span>
<span class="line">        <span class="token keyword static-context">parent</span><span class="token operator">::</span><span class="token function">__construct</span><span class="token punctuation">(</span><span class="token variable">$config</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">init</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token keyword static-context">parent</span><span class="token operator">::</span><span class="token function">init</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line">        <span class="token comment">// ... 应用配置后进行初始化</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>另外，为了让组件可以在创建实例时 <a href="https://learnku.com/docs/yii-framework/2.0.x/component/concept-configurations.md" target="_blank" rel="noopener noreferrer">能被正确配置</a>，请遵照以下操作流程：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$component</span> <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">MyClass</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string single-quoted-string">'prop1'</span> <span class="token operator">=></span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'prop2'</span> <span class="token operator">=></span> <span class="token number">4</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token comment">// 方法二：</span></span>
<span class="line"><span class="token variable">$component</span> <span class="token operator">=</span> <span class="token class-name class-name-fully-qualified static-context"><span class="token punctuation">\</span>Yii</span><span class="token operator">::</span><span class="token function">createObject</span><span class="token punctuation">(</span><span class="token punctuation">[</span></span>
<span class="line">    <span class="token string single-quoted-string">'class'</span> <span class="token operator">=></span> <span class="token class-name static-context">MyClass</span><span class="token operator">::</span><span class="token keyword">class</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token string single-quoted-string">'prop1'</span> <span class="token operator">=></span> <span class="token number">3</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token string single-quoted-string">'prop2'</span> <span class="token operator">=></span> <span class="token number">4</span><span class="token punctuation">,</span></span>
<span class="line"><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote>
<p>Info: 尽管调用 [[Yii::createObject()]] 的方法看起来更加复杂，但这主要因为它更加灵活强大，它是基于 <a href="https://learnku.com/docs/yii-framework/2.0.x/component/concept-di-container.md" target="_blank" rel="noopener noreferrer">依赖注入容器</a> 实现的。</p>
</blockquote>
<h2 id="组件执行生命周期" tabindex="-1"><a class="header-anchor" href="#组件执行生命周期"><span>组件执行生命周期</span></a></h2>
<p>[[yii\base\BaseObject]] 类执行时的生命周期如下：</p>
<ol>
<li>构造方法内的预初始化过程。你可以在这儿给各属性设置缺省值。</li>
<li>通过 <code v-pre>$config</code> 配置对象。配置的过程可能会覆盖掉先前在构造方法内设置的默认值。</li>
<li>在 [[yii\base\BaseObject::init()|init()]] 方法内进行初始化后的收尾工作。你可以通过重写此方法，进行一些良品检验，属性的初始化之类的工作。</li>
<li>对象方法调用。</li>
</ol>
<p>前三步都是在对象的构造方法内发生的。这意味着一旦你获得了一个对象实例（即一个对象），<br>
那么它就已经初始化就绪可供使用。</p>
<h2 id="ui-组件" tabindex="-1"><a class="header-anchor" href="#ui-组件"><span>UI 组件</span></a></h2>
<p>以小部件 [[yii\jui\DatePicker|日期选择器]] 来举例，这是个方便你在 <a href="https://learnku.com/docs/yii-framework/2.0.x/views/12005" target="_blank" rel="noopener noreferrer">视图</a> 中生成一个交互式日期选择器的 UI 组件：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">yii<span class="token punctuation">\</span>jui<span class="token punctuation">\</span>DatePicker</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">echo</span> <span class="token class-name static-context">DatePicker</span><span class="token operator">::</span><span class="token function">widget</span><span class="token punctuation">(</span><span class="token punctuation">[</span></span>
<span class="line">    <span class="token string single-quoted-string">'language'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'zh-CN'</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token string single-quoted-string">'name'</span>  <span class="token operator">=></span> <span class="token string single-quoted-string">'country'</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token string single-quoted-string">'clientOptions'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token string single-quoted-string">'dateFormat'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'yy-mm-dd'</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>这个小部件继承自 <code v-pre>yii\base\Component</code>，它的各项属性改写起来会很容易。</p>
<h2 id="应用组件" tabindex="-1"><a class="header-anchor" href="#应用组件"><span>应用组件</span></a></h2>
<p>应用主体是 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/concept-service-locator.md" target="_blank" rel="noopener noreferrer">服务定位器</a>，它部署一组提供各种不同功能的 <em>应用组件</em> 来处理请求。例如，<code v-pre>urlManager</code> 组件负责处理网页请求路由到对应的控制器，<code v-pre>db</code> 组件提供数据库相关服务等。</p>
<p>在同一个应用中，每个应用组件都有一个独一无二的 ID 用来区分其他应用组件，你可以通过如下表达式访问应用组件：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token class-name class-name-fully-qualified static-context"><span class="token punctuation">\</span>Yii</span><span class="token operator">::</span><span class="token variable">$app</span><span class="token operator">-></span><span class="token property">componentID</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>例如，可以使用 <code v-pre>\Yii::$app-&gt;db</code> 来获取到已注册到应用的数据库连接（<code v-pre>yii\db\Connection</code>）组件， 使用 <code v-pre>\Yii::$app-&gt;cache</code> 来获取到已注册到应用的主缓存（<code v-pre>yii\caching\Cache</code>）组件。</p>
<p>第一次使用以上表达式时候会创建应用组件实例，后续再访问会返回此实例，无需再次创建。</p>
<p>应用组件可以是任意对象，可以在 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/structure-applications.md#application-configurations" target="_blank" rel="noopener noreferrer">应用主体配置</a> 中配置 [[yii\base\Application::components]] 属性。 例如：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token punctuation">[</span></span>
<span class="line">    <span class="token string single-quoted-string">'components'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token comment">// 使用类名注册 "cache" 组件</span></span>
<span class="line">        <span class="token string single-quoted-string">'cache'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'yii\caching\ApcCache'</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token comment">// 使用配置数组注册 "db" 组件</span></span>
<span class="line">        <span class="token string single-quoted-string">'db'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">            <span class="token string single-quoted-string">'class'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'yii\db\Connection'</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token string single-quoted-string">'dsn'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'mysql:host=localhost;dbname=demo'</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token string single-quoted-string">'username'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'root'</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token string single-quoted-string">'password'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">''</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line">        <span class="token comment">// 使用函数注册"search" 组件</span></span>
<span class="line">        <span class="token string single-quoted-string">'search'</span> <span class="token operator">=></span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">            <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name class-name-fully-qualified">app<span class="token punctuation">\</span>components<span class="token punctuation">\</span>SolrService</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"><span class="token punctuation">]</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote>
<p>Info: 请谨慎注册太多应用组件，应用组件就像全局变量，使用太多可能加大测试和维护的难度。 一般情况下可以在需要时再创建本地组件。</p>
</blockquote>
<h3 id="引导启动组件" tabindex="-1"><a class="header-anchor" href="#引导启动组件"><span>引导启动组件</span></a></h3>
<p>上面提到一个应用组件只会在第一次访问时实例化，如果处理请求过程没有访问的话就不实例化。有时，你想在每个请求处理过程都实例化某个组件即便它不会被访问，可以将该组件ID加入到应用主体的 [[yii\base\Application::bootstrap]] 属性中。</p>
<p>你还可以使用闭包来引导启动自定义的组件。不需要直接返回一个实例化的组件。在应用主体 <code v-pre>yii\base\Application</code> 实例化后，闭包也会被调用。</p>
<p>例如, 如下的应用主体配置保证了 <code v-pre>log</code> 组件一直被加载。</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token punctuation">[</span></span>
<span class="line">    <span class="token string single-quoted-string">'bootstrap'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token string single-quoted-string">'log'</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token variable">$app</span><span class="token punctuation">)</span><span class="token punctuation">{</span></span>
<span class="line">            <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">ComponentX</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token punctuation">}</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token variable">$app</span><span class="token punctuation">)</span><span class="token punctuation">{</span></span>
<span class="line">            <span class="token comment">// 可以写自定义的代码</span></span>
<span class="line">           <span class="token keyword">return</span><span class="token punctuation">;</span></span>
<span class="line">        <span class="token punctuation">}</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token string single-quoted-string">'components'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token string single-quoted-string">'log'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">            <span class="token comment">// "log" 组件的配置</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"><span class="token punctuation">]</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="核心应用组件" tabindex="-1"><a class="header-anchor" href="#核心应用组件"><span>核心应用组件</span></a></h3>
<p>Yii 定义了一组固定ID和默认配置的 <em>核心</em> 组件，例如 [[yii\web\Application::request]] 组件用来收集用户请求并解析 <a href="https://learnku.com/docs/yii-framework/2.0.x/routes/11998" target="_blank" rel="noopener noreferrer">路由</a>； [[yii\base\Application::db]] 代表一个可以执行数据库操作的数据库连接。通过这些组件，Yii应用主体能处理用户请求。</p>
<p>下面是预定义的核心应用组件列表，可以和普通应用组件一样配置和自定义它们。当你配置一个核心组件，不指定它的类名的话就会使用 Yii 默认指定的类。</p>
<ul>
<li><code v-pre>yii\web\AssetManager</code>: assetManager 组件，管理资源包和资源发布，详情请参考 <a href="https://learnku.com/docs/yii-framework/2.0.x/front-end-assets/12021" target="_blank" rel="noopener noreferrer">管理资源</a> 一节。</li>
<li><code v-pre>yii\db\Connection</code>: db 组件，代表一个可以执行数据库操作的数据库连接， 注意配置该组件时必须指定组件类名和其他相关组件属性，如 [[yii\db\Connection::dsn]]。详情请参考 <a href="https://learnku.com/docs/yii-framework/2.0.x/database-access-object-dao/12023" target="_blank" rel="noopener noreferrer">数据访问对象</a> 一节。</li>
<li><code v-pre>yii\base\Application::errorHandler</code>: errorHandler 组件，处理 PHP 错误和异常，详情请参考 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/tutorial-handling-errors.md" target="_blank" rel="noopener noreferrer">错误处理</a> 一节。</li>
<li><code v-pre>yii\i18n\Formatter</code>: formatter 组件，格式化输出显示给终端用户的数据，例如数字可能要带分隔符，日期使用长格式。详情请参考 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/output-formatting.md" target="_blank" rel="noopener noreferrer">格式化输出数据</a> 一节。</li>
<li><code v-pre>yii\i18n\I18N</code>: i18n 组件，支持信息翻译和格式化。 详情请参考 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/tutorial-i18n.md" target="_blank" rel="noopener noreferrer">国际化</a> 一节。</li>
<li><code v-pre>yii\log\Dispatcher</code>: log 组件，管理日志对象。详情请参考 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/tutorial-logging.md" target="_blank" rel="noopener noreferrer">日志</a> 一节。</li>
<li><code v-pre>yii\swiftmailer\Mailer</code>: mail 组件，支持生成邮件结构并发送，详情请参考 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/tutorial-mailing.md" target="_blank" rel="noopener noreferrer">邮件</a> 一节。</li>
<li><code v-pre>yii\base\Application::response</code>: response 组件，代表发送给用户的响应，详情请参考 <a href="https://learnku.com/docs/yii-framework/2.0.x/response/12067" target="_blank" rel="noopener noreferrer">响应</a> 一节。</li>
<li><code v-pre>yii\base\Application::request</code>: request 组件，代表从终端用户处接收到的请求，详情请参考 <a href="https://learnku.com/docs/yii-framework/2.0.x/request/12043" target="_blank" rel="noopener noreferrer">请求</a> 一节。</li>
<li><code v-pre>yii\web\Session</code>: session 组件，代表会话信息，仅在 <code v-pre>yii\web\Application</code> 网页应用中可用，详情请参考 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/runtime-sessions-cookies.md" target="_blank" rel="noopener noreferrer">Sessions (会话) and Cookies</a> 一节。</li>
<li><code v-pre>yii\web\UrlManager</code>: urlManager 组件，支持URL地址解析和创建，详情请参考 <a href="https://learnku.com/docs/yii-framework/2.0.x/routes/11998#4f88e8" target="_blank" rel="noopener noreferrer">URL 解析和生成</a> 一节。</li>
<li><code v-pre>yii\web\User</code>: user 组件，代表认证登录用户信息，仅在 <code v-pre>yii\web\Application</code> 网页应用中可用，详情请参考 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/security-authentication.md" target="_blank" rel="noopener noreferrer">认证</a> 一节。</li>
<li><code v-pre>yii\web\View</code>: view 组件，支持渲染视图，详情请参考 <a href="https://learnku.com/docs/yii-framework/2.0.x/views/12005" target="_blank" rel="noopener noreferrer">视图</a> 一节。</li>
</ul>
<blockquote>
<p>💖喜欢本文档的，欢迎点赞、收藏、留言或转发，谢谢支持！<br>
作者邮箱：zhuzixian520@126.com，github地址：<a href="https://github.com/zhuzixian520" target="_blank" rel="noopener noreferrer">github.com/zhuzixian520</a></p>
</blockquote>
</div></template>


